package com.prs.crm.dao.crm.impl;

import java.sql.SQLException;
import java.util.Date;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.hibernate3.HibernateCallback;
import com.prs.crm.dao.crm.SerCurrentDateDao;
import com.prs.crm.dao.impl.BaseDaoImpl;
import com.prs.crm.domain.crm.SerCurrentDate;

public class SerCurrentDateDaoImpl extends BaseDaoImpl<SerCurrentDate>
		implements SerCurrentDateDao {

	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public List<SerCurrentDate> getByDate(final Date date) {
		return (List<SerCurrentDate>) this.getHibernateTemplate().execute(
				new HibernateCallback(){
					@Override
					public Object doInHibernate(Session arg0)
							throws HibernateException, SQLException {
						Criteria criteria = arg0.createCriteria(SerCurrentDate.class);
						criteria.add(Restrictions.eq("dateFund", date));
						return criteria.list();
					}
					
				}
			);
	}
	@SuppressWarnings({ "unchecked", "rawtypes" })
	@Override
	public List<SerCurrentDate> getByCurrentTimeData() {
		return (List<SerCurrentDate>) this.getHibernateTemplate().execute(
				new HibernateCallback(){
					@Override
					public Object doInHibernate(Session arg0)
							throws HibernateException, SQLException {
						Criteria criteria = arg0.createCriteria(SerCurrentDate.class);
						
						return criteria.list();
					}
					
				}
			);
	}



}
